const jwt = require('jsonwebtoken');
const { jwtKey } = require('../config/index');

module.exports = {
  // 对 data 加密 默认时间是7天
  sign(data, expiresIn = 1 * 60 * 60 * 24 * 7) {
    return jwt.sign({ data }, jwtKey, { expiresIn: expiresIn });
  },
  verify(data) {
    return jwt.verify(data, jwtKey);
  },
};
